package com.create404.suishoupai.config;

import com.create404.suishoupai.filter.AuthHandlerInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * TODO
 *
 * @author Stephana
 * date 2021/7/22 14:14
 * @version 1.0
 * @Description 录制要拦截的路径
 */
@Configuration
public class AuthWebMvcConfigurer implements WebMvcConfigurer {
    @Autowired
    AuthHandlerInterceptor authHandlerInterceptor;

    /**
     * 给除了 /login 的接口都配置拦截器,拦截转向到 authHandlerInterceptor
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authHandlerInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/**/webjars/**","/**/webjars/bycdao-ui/**","/**/swagger-resources/**", "/**/employee/login/**","/**/employee/updatePasswordbyPhone/**", "/**/employee/register/**");
    }
}

